class Solution(object):
    def stoneGameIII(self, stoneValue):
        n = len(stoneValue)
        DP = [0] * n
        for i in range(n - 1, -1, -1):
            if i == n - 1:
                DP[i] = stoneValue[i]
            else:
                now = 0
                max_val = - float('inf')
                for k in range(i, min(i + 3, n)):
                    now += stoneValue[k]
                    if k < n - 1:
                        max_val = max(max_val, now - DP[k + 1])
                    else:
                        max_val = max(max_val, now)
                DP[i] = max_val
        if DP[0] > 0:
            return 'Alice'
        if DP[0] < 0:
            return 'Bob'
        if DP[0] == 0:
            return 'Tie'
